﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using Microsoft.TeamFoundation.WorkItemTracking.Client;
using ScrumTable.Common;

#endregion

namespace ScrumTable.DL.Data.TFS.Services.TeamFoundation
{
    /// <summary>
    /// This class provides additional functionalities for field
    /// handling.
    /// </summary>
    public static class TfsField
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Returns true if the current field is read only.
        /// </summary>
        /// <param name="tfsField">Input pointer for the field.</param>
        public static bool IsReadOnly(this Field tfsField)
        {
            PreCondition.AssertNotNull(tfsField, "tfsField");

            return (tfsField.InvalidateProperties() && !tfsField.IsEditable);
        }

        /// <summary>
        /// Invalidates the properties (states) of the field and returns true
        /// if the invalidation process has been completed successfully.
        /// </summary>
        /// <param name="tfsField">Input pointer for the field.</param>
        public static bool InvalidateProperties(this Field tfsField)
        {
            PreCondition.AssertNotNull(tfsField, "tfsField");

            return (/*force invalidate field*/ tfsField.AllowedValues != null);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}